<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>所有评论</title>
     <#include "../common/header.ftl">
</head>

<body>
<div class="content-wrapper" style="display: flex">
    <div class="nav-wrapper" style="flex: 0 0 200px;width: 200px">
        <#include "../common/nav.ftl">
    </div>
    <div id="page-content-wrapper" style="flex: 1;margin-left: 20px;margin-top: 100px">
        <div class="col-md-12 column">
            <div id="modal-container" class="modal" style="display: none">
                <form action="/sell/remark/admin/addbyid" method="get">
                    <div class="modal-dialog" id="categoryDialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="close">
                                    &times;
                                </button>
                                <h4 class="modal-title" id="myModalLabel">回复:</h4>
                                <img width="45dp" height="45dp" src="" id="img_headimg">&nbsp;&nbsp;&nbsp;
                                <input id="input_nickname" type="text" value=""
                                       style="border: 0px;outline:none;cursor: pointer;" disabled>
                            </div>
                            <div class="modal-body">
                                <input id="categoryId" style="display: none" value="">
                                评论号：<input id="input_remarkid" type="text" value="" disabled
                                           style="border: 0px;outline:none;cursor: pointer;">
                                订单号：<input id="input_orderid" type="text" value="" disabled
                                           style="border: 0px;outline:none;cursor: pointer;"><br><br><br>
                                内容：<input id="input_comment" name="comment" type="text" value="" placeholder="请输入">
                                <input style="display: none" name="headImg" value="">
                                <input style="display: none" name="nickName" value="">
                                <input style="display: none" name="openid" value="${openid}">
                                <input style="display: none" name="orderId" id="add_orderId">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close">关闭
                                </button>
                                <input type="submit" value="回复">
                            </div>
                        </div>
                    </div>
                </form>

            </div>
            <div id="modal-container2" class="modal" style="display: none">
                <form action="/sell/remark/admin/updatebyid" method="post">
                    <div class="modal-dialog" id="categoryDialog2">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                                        id="downclose">&times;
                                </button>
                                <h4 class="modal-title" id="myModalLabel2">修改评论</h4>
                            </div>
                            <div class="modal-body">
                                <input id="categoryId2" style="display: none" value="">
                                评论号：<input id="input_remarkid2" type="text" value="" disabled
                                           style="border: 0px;outline:none;cursor: pointer;">
                                订单号：<input id="input_orderid2" type="text" value="" disabled
                                           style="border: 0px;outline:none;cursor: pointer;"><br><br><br>
                                原内容：<input id="input_comment2" type="text" value="" disabled
                                           style="border: 0px;outline:none;cursor: pointer;">
                                <input style="display: none" name="remarkId" id="up_remarkId">
                                <input style="display: none" name="orderId" id="up_orderId">
                                修改内容：<input id="input_comment3" type="text" name="comment" value="" placeholder="请输入">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close2">关闭
                                </button>
                                <input style="display: none" name="headImg" value="">
                                <input style="display: none" name="nickName" value="">
                                <input style="display: none" name="openid" value="${openid}">
                                <input type="submit" <#--class="btn btn-primary"--> value="更新asd 评论">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <form role="form" action="/sell/remark/admin/byOrderId" method="get">
                <tr>
                    订单号查询：
                    <td><input type="text" name="orderId" value=""></td>
                    <td><input type="submit" value="查询" formmethod="get" id="input_byId"></td>
                    <td><input type="text" name="openid" value="${openid}" style="display: none"></td>

                </tr>
            </form>
            <form role="form" action="/sell/remark/admin/byTimeScope" method="get" style="margin-top: 20px">
                <tr>
                    时间范围：
                    <td><input type="date" id="input_startTime" name="startTime" value=""></td>
                    <td>至&nbsp;<input type="date" id="input_endTime" name="endTime" value=""></td>
                    <td><input type="submit" value="查询"></td>
                    <td><input type="text" name="openid" value="${openid}" style="display: none"></td>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="a_return"
                                                           href="/sell/remark/admin/remarklist?openid=${openid}">所有评论</a>
                </tr>
            </form>
            <table class="table" table-bordered style="margin-top: 20px">

                <tr>

                    <td>评论id</td>
                    <td>订单id</td>
                    <td>头像</td>
                    <td>昵称</td>
                    <td>内容</td>
                    <td>更新时间</td>
                    <td>创建时间</td>
                    <td colspan="1">操作</td>
                </tr>
    <#list pages.content as hashmap>
        <#if hashmap["business"]??&&hashmap["business"]=="">
            <#if (hashmap["user"]!="")>
                <tr class="success">
                    <td>${hashmap["user"].remarkId}</td>
                    <td>${hashmap["user"].orderId}</td>
                    <td><img width="50dp" height="50dp" src="${hashmap["user"].headImg}"></td>
                    <td>${hashmap["user"].nickName}</td>
                    <td>${hashmap["user"].comment}</td>
                    <td>${hashmap["user"].updateTime}</td>
                    <td>${hashmap["user"].createTime}</td>
                    <td>

                        <input width="100sp" type="button" value="回复" class="btn_remark"
                               style="background-color: #7ED321;"> </input>

                    </td>
                </tr>
            </#if>
        <#else>
            <#if (hashmap["user"]!="")>
                <tr class="success">
                    <td>${hashmap["user"].remarkId}</td>
                    <td>${hashmap["user"].orderId}</td>
                    <td><img width="50dp" height="50dp" src="${hashmap["user"].headImg}"></td>
                    <td>${hashmap["user"].nickName}</td>
                    <td>${hashmap["user"].comment}</td>
                    <td>${hashmap["user"].updateTime}</td>
                    <td>${hashmap["user"].createTime}</td>
                </tr>
            </#if>
            <#if (hashmap["business"]!="")>
                    <tr class="success">
                        <td>${hashmap["business"].remarkId}</td>
                        <td>${hashmap["business"].orderId}</td>
                        <td><img width="50dp" height="50dp" src="${hashmap["business"].headImg}"></td>
                        <td>${hashmap["business"].nickName}</td>
                        <td>${hashmap["business"].comment}</td>
                        <td>${hashmap["business"].updateTime}</td>
                        <td>${hashmap["business"].createTime}</td>
                        <td>
                            <div>
                                <input width="100sp" type="button" value="修改评论" class="btn_update"
                                       style="background-color: #7ED321;">
                            </div>
                            <div>
                                <a href="/sell/remark/admin/deletebyid?remarkId=${hashmap["business"].remarkId}&openid=${openid}">
                                    <input width="100sp" type="button" value="删除评论"
                                           style="background-color: #e71d18;"
                                           onclick="if(confirm('确认删除评论？')){this.form.submit();}">
                                </a>
                            </div>
                        </td>
                    </tr>
            </#if>
        </#if>
    </#list>

            </table>
            <ul class="pagination pull-right">
                    <#if currentPage lt 1>
                        <li class="disabled"><a href="#">上一页</a></li>
                    <#else>
                        <li><a href="/sell/remark/admin/remarklist?page=${currentPage}&size=${size}">上一页</a></li>
                    </#if>
                    <#if pages.getTotalPages()<1>
                        <#list 1.. as index>
                            <#if currentPage+1 == index>
                            <li class="disabled"><a href="#">${index}</a></li>
                            <#else>
                            <li><a href="/sell/remark/admin/remarklist?page=${index}&size=${size}">${index}</a></li>
                            </#if>
                        </#list>
                    <#else>
                        <#list 1..pages.getTotalPages() as index>
                            <#if currentPage+1 == index>
                            <li class="disabled"><a href="#">${index}</a></li>
                            <#else>
                            <li><a href="/sell/remark/admin/remarklist?page=${index}&size=${size}">${index}</a></li>
                            </#if>
                        </#list>
                    </#if>



                    <#if currentPage+1 gte pages.getTotalPages()>
                        <li class="disabled"><a href="#">下一页</a></li>
                    <#else>
                        <li><a href="/sell/remark/admin/remarklist?page=${currentPage + 2}&size=${size}">下一页</a></li>
                    </#if>
            </ul>
        </div>
    </div>
</div>
<script>
    /*逻辑控制代码*/

    /*点击回复按钮弹框*/
    $(".btn_remark").click(function () {
        var remark_id = $(this).parent('td').parent('tr').children('td').eq(0).text();
        var order_id = $(this).parent('td').parent('tr').children('td').eq(1).text();
        var head_img = $(this).parent('td').parent('tr').children('td').eq(2).text();
        var nick_name = $(this).parent('td').parent('tr').children('td').eq(3).text();

        var modifyClass = document.getElementById('modal-container');
        modifyClass.setAttribute('style', 'display:block');

        var headimg = document.getElementById('img_headimg');
        headimg.src = head_img;
        var nickname = document.getElementById('input_nickname');
        nickname.value = nick_name;
        var remarkid = document.getElementById('input_remarkid');
        remarkid.value = remark_id;
        var orderid = document.getElementById('input_orderid');
        orderid.value = order_id;
        var addorder = document.getElementById('add_orderId');
        addorder.value = order_id;

    });
    /*点击修改评论弹框*/
    $(".btn_update").click(function () {
        var remark_id2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(0).text();
        var order_id2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(1).text();
        var head_img2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(2).text();
        var nick_name2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(3).text();
        var comment = $(this).parent('div').parent('td').parent('tr').children('td').eq(4).text();
        console.log(remark_id2 + "ss" + order_id2);
        var modifyClass = document.getElementById('modal-container2');
        modifyClass.setAttribute('style', 'display:block');
        var remarkid = document.getElementById('input_remarkid2');
        remarkid.value = remark_id2;
        var orderid = document.getElementById('input_orderid2');
        orderid.value = order_id2;
        var comment2 = document.getElementById('input_comment2');
        comment2.value = comment;
        var formorid = document.getElementById('up_orderId');
        formorid.value = order_id2;
        var formrid = document.getElementById('up_remarkId');
        formrid.value = remark_id2;


    });
    /*回复弹框关闭，右上角×*/
    $("#close").click(function () {
        var modifyClass = document.getElementById('modal-container');
        modifyClass.setAttribute('style', 'display:none');
    });
    /*修改评论弹框关闭，右上角×*/
    $("#downclose").click(function () {
        var modifyClass = document.getElementById('modal-container2');
        modifyClass.setAttribute('style', 'display:none');
    });
    /*回复弹框关闭按钮*/
    $("#btn_close").click(function () {
        var modifyClass = document.getElementById('modal-container');
        modifyClass.setAttribute('style', 'display:none');
    });
    /*修改评论关闭按钮*/
    $("#btn_close2").click(function () {
        var modifyClass = document.getElementById('modal-container2');
        modifyClass.setAttribute('style', 'display:none');
    });
    /*点击回复按钮弹框*/
    $(".btn_remark").click(function () {
        var remark_id = $(this).parent('td').parent('tr').children('td').eq(0).text();
        var order_id = $(this).parent('td').parent('tr').children('td').eq(1).text();
        var head_img = $(this).parent('td').parent('tr').children('td').eq(2).text();
        var nick_name = $(this).parent('td').parent('tr').children('td').eq(3).text();

        var modifyClass = document.getElementById('modal-container');
        modifyClass.setAttribute('style', 'display:block');

        var headimg = document.getElementById('img_headimg');
        headimg.src = head_img;
        var nickname = document.getElementById('input_nickname');
        nickname.value = nick_name;
        var remarkid = document.getElementById('input_remarkid');
        remarkid.value = remark_id;
        var orderid = document.getElementById('input_orderid');
        orderid.value = order_id;
        var addorder = document.getElementById('add_orderId');
        addorder.value = order_id;

    });
    /*点击修改评论弹框*/
    $(".btn_update").click(function () {
        var remark_id2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(0).text();
        var order_id2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(1).text();
        var head_img2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(2).text();
        var nick_name2 = $(this).parent('div').parent('td').parent('tr').children('td').eq(3).text();
        var comment = $(this).parent('div').parent('td').parent('tr').children('td').eq(4).text();
        console.log(remark_id2 + "ss" + order_id2);
        var modifyClass = document.getElementById('modal-container2');
        modifyClass.setAttribute('style', 'display:block');
        var remarkid = document.getElementById('input_remarkid2');
        remarkid.value = remark_id2;
        var orderid = document.getElementById('input_orderid2');
        orderid.value = order_id2;
        var comment2 = document.getElementById('input_comment2');
        comment2.value = comment;
        var formorid = document.getElementById('up_orderId');
        formorid.value = order_id2;
        var formrid = document.getElementById('up_remarkId');
        formrid.value = remark_id2;


    });
    /*
    $("#submit_findbytime").click(function () {
        var x1 = document.getElementById('input_startTime').value;
        var x2 = document.getElementById('input_endTime').value;
        var startTime = x1.substring(0,4)+"-"+x1.substring(5,7)+"-"+x1.substring(8,10)+" "+x1.substring(11,13)+":"+x1.substring(14,16)+":00";
        var endTime = x2.substring(0,4)+"-"+x2.substring(5,7)+"-"+x2.substring(8,10)+" "+x2.substring(11,13)+":"+x2.substring(14,16)+":00";
        console.log(startTime+"   "+endTime);
        $.get('/sell/remark/admin/byTimeScope',
                {
                    "startTime": startTime,
                    "endTime": endTime
                },
                function (data) {
                    var tmp = $.parseJSON(data);
                    console.log(tmp);
                    if (tem.mcode != "1") {
                        alert(tem.msg);
                    }
                });
        var modifyClass = document.getElementById('modal-container2');
        modifyClass.setAttribute('style', 'display:none');

    });*/
</script>


</body>
</html>
